unit uLanguageSet;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,BaseForm, cxGraphics, cxControls,
  cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore,
  dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee,
  dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010,
  dxSkinWhiteprint, dxSkinXmas2008Blue, dxSkinscxPCPainter, cxPCdxBarPopupMenu,
  cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, cxNavigator, Data.DB,
  cxDBData, Vcl.ExtCtrls, cxGridLevel, cxClasses, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, cxPC,
  cxGroupBox, Datasnap.DBClient, ClientRowSet, cxImageComboBox, Vcl.Menus,
  Vcl.StdCtrls, cxButtons;

type
  TFrmLanguageSet = class(TBaseForm)
    cxPageControl1: TcxPageControl;
    cxTabSheet1: TcxTabSheet;
    GrdMaster: TcxGrid;
    tvMaster: TcxGridDBTableView;
    lvMaster: TcxGridLevel;
    Splitter1: TSplitter;
    cxPageControl2: TcxPageControl;
    cxTabSheet2: TcxTabSheet;
    GrdDetail: TcxGrid;
    tvDetail: TcxGridDBTableView;
    lvDetail: TcxGridLevel;
    crsMaster: TClientRowSet;
    crsDetail: TClientRowSet;
    dsMaster: TDataSource;
    dsDetail: TDataSource;
    crsMasterID: TStringField;
    crsMasterTYPE: TSmallintField;
    crsMasterNAME: TStringField;
    crsMasterCAPTION: TStringField;
    crsMasterGROUP_CODE: TStringField;
    crsDetailID: TStringField;
    crsDetailM_ID: TStringField;
    crsDetailLABEL_NAME: TStringField;
    crsDetailLANGUAGE_1: TStringField;
    crsDetailLANGUAGE_2: TStringField;
    crsDetailLANGUAGE_3: TStringField;
    crsDetailLANGUAGE_4: TStringField;
    crsDetailLANGUAGE_5: TStringField;
    crsDetailLANGUAGE_6: TStringField;
    crsDetailLANGUAGE_7: TStringField;
    crsDetailLANGUAGE_8: TStringField;
    crsDetailLANGUAGE_9: TStringField;
    crsDetailLANGUAGE_10: TStringField;
    crsDetailUPDATEBY: TStringField;
    crsDetailUPDATETIME: TStringField;
    tvMasterTYPE: TcxGridDBColumn;
    tvMasterNAME: TcxGridDBColumn;
    tvMasterCAPTION: TcxGridDBColumn;
    tvDetailLABEL_NAME: TcxGridDBColumn;
    tvDetailLANGUAGE_1: TcxGridDBColumn;
    tvDetailLANGUAGE_2: TcxGridDBColumn;
    tvDetailLANGUAGE_3: TcxGridDBColumn;
    tvDetailLANGUAGE_4: TcxGridDBColumn;
    tvDetailLANGUAGE_5: TcxGridDBColumn;
    tvDetailLANGUAGE_6: TcxGridDBColumn;
    tvDetailLANGUAGE_7: TcxGridDBColumn;
    tvDetailLANGUAGE_8: TcxGridDBColumn;
    tvDetailLANGUAGE_9: TcxGridDBColumn;
    tvDetailLANGUAGE_10: TcxGridDBColumn;
    tvDetailUPDATEBY: TcxGridDBColumn;
    tvDetailUPDATETIME: TcxGridDBColumn;
    cxGroupBox1: TcxGroupBox;
    cxButton11: TcxButton;
    cxButton1: TcxButton;
    Label2: TLabel;
    procedure crsDetailAfterEdit(DataSet: TDataSet);
    procedure cxButton11Click(Sender: TObject);
    procedure cxButton1Click(Sender: TObject);
    procedure crsDetailAfterPost(DataSet: TDataSet);
    procedure dsDetailStateChange(Sender: TObject);
  private
    { Private declarations }
  public
    procedure InitForm;
    { Public declarations }
  end;

var
  FrmLanguageSet: TFrmLanguageSet;

implementation

uses
  uDm, ucommFunction, Console;

{$R *.dfm}

procedure TFrmLanguageSet.crsDetailAfterEdit(DataSet: TDataSet);
begin
  DataSet.FieldByName('updateby').AsString:=userInfo.userNo;
  dataset.FieldByName('updatetime').AsString:=DateTimeToStr(Now);
end;

procedure TFrmLanguageSet.crsDetailAfterPost(DataSet: TDataSet);
begin
  crsDetail.ApplyUpdates;
end;

procedure TFrmLanguageSet.cxButton11Click(Sender: TObject);
begin
  crsDetail.ApplyUpdates;
  dm.crsLanguage.Refresh;
end;

procedure TFrmLanguageSet.cxButton1Click(Sender: TObject);
begin
  crsDetail.CancelUpdates;
end;

procedure TFrmLanguageSet.dsDetailStateChange(Sender: TObject);
begin
  cxButton1.Enabled:=crsDetail.State in [dsEdit,dsInsert];
  cxButton11.Enabled:=crsDetail.State in [dsEdit,dsInsert];
end;

procedure TFrmLanguageSet.InitForm;
var
  sqls:string;
begin
  sqls:='select '+GetClientRowSetColumns(crsMaster)+' from sys_language';
  OpenDataSet(sqls,crsMaster);
  sqls:='select '+GetClientRowSetColumns(crsDetail)+' from sys_language_detail';
  OpenDataSet(sqls,crsDetail);
end;

end.
